package com.quanyan.runningriding.service.impl;

import com.quanyan.common.Plugin.PageObj;
import com.quanyan.runningriding.entity.vo.run.resp.MusicLovePersonVo;
import com.quanyan.runningriding.entity.vo.run.resp.MusicPlayPersonVo;
import com.quanyan.runningriding.mapper.RunMusicStatisticsMapper;
import com.quanyan.runningriding.service.RunMusicStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by liubin on 2016/11/19.
 */
@Service
public class RunMusicStatisticsServiceImpl implements RunMusicStatisticsService{
    @Autowired
    private RunMusicStatisticsMapper runMusicStatisticsMapper;

    @Override
    public PageObj<List<MusicLovePersonVo>> musicLovePersonList(String markLoveMinTime, String markLoveMaxTime, Byte isCache, Integer pageNum, Integer pageSize) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("markLoveMinTime", markLoveMinTime);
        paramMap.put("markLoveMaxTime", markLoveMaxTime);
       //1缓存 0没缓存
        paramMap.put("isCache", isCache);
        paramMap.put("pageStart", (pageNum - 1) * pageSize);
        paramMap.put("pageSize", pageSize);
        List<MusicLovePersonVo> musicLovePersonVos=runMusicStatisticsMapper.musicLovePersonList(paramMap);
        Integer total=runMusicStatisticsMapper.musicLovePersonListCount(paramMap)==null?0:runMusicStatisticsMapper.musicLovePersonListCount(paramMap);
        PageObj<List<MusicLovePersonVo>> result=PageObj.create(total, pageNum, pageSize, musicLovePersonVos);
        return result;
    }

    @Override
    public PageObj<List<MusicPlayPersonVo>> musicCollectionPlayPersonList(String playMinTime, String playMaxTime, Integer pageNum, Integer pageSize) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("playMinTime", playMinTime);
        paramMap.put("playMaxTime", playMaxTime);
        paramMap.put("pageStart", (pageNum - 1) * pageSize);
        paramMap.put("pageSize", pageSize);
        List<MusicPlayPersonVo> musicLovePersonVos=runMusicStatisticsMapper.musicCollectionPlayPersonList(paramMap);
        Integer total=runMusicStatisticsMapper.musicCollectionPlayPersonListCount(paramMap);
        PageObj<List<MusicPlayPersonVo>> result=PageObj.create(total, pageNum, pageSize, musicLovePersonVos);
        return result;
    }


}